﻿using System;
using System.Collections.Generic;
using System.Text;

namespace iFinity.DNN.Modules.CacheMaster.Entities
{
    public class CacheItemInfoCol  : List<CacheItemInfo>
    {

        public void SortByType()
        {
            this.Sort(new CacheItemTypeSorter());
        }
        public void SortByKey()
        {
            this.Sort(new CacheItemKeySorter());
        }
    }
    public class CacheItemTypeSorter : IComparer<CacheItemInfo>
    {
        public int Compare(CacheItemInfo obj1, CacheItemInfo obj2)
        {
            return obj1.CacheObjectType.CompareTo(obj2.CacheObjectType);
        }
    }
    public class CacheItemKeySorter : IComparer<CacheItemInfo>
    {
        public int Compare(CacheItemInfo obj1, CacheItemInfo obj2)
        {
            return obj1.CacheKey.CompareTo(obj2.CacheKey);
        }
    }
    public class CacheItemCreatedSorter : IComparer<CacheItemInfo>
    {
        public int Compare(CacheItemInfo obj1, CacheItemInfo obj2)
        {
            return obj1.UtcCreatedDate.CompareTo(obj2.UtcCreatedDate);
        }
    }
}
